class DateFormat {
    private static _instance: DateFormat;
    constructor(
        private nowDate: any = new Date()
    ) { }

    public static get Instance() {
        return this._instance || (this._instance = new this());
    }

    formatOrderTime(date: any): any {
        let nowTime: any = new Date().getTime();
        date = date.substring(0, 19);
        date = date.replace(/-/g, '/');
        let time: any = new Date(date).getTime();
        let resTime = (time - nowTime) / 1000;
        let day = Math.floor(resTime / (24 * 60 * 60));
        let hour = Math.floor(resTime % (24 * 60 * 60) / (60 * 60))
        let minute = Math.floor(resTime % (24 * 60 * 60) % (60 * 60) / 60);
        let second = Math.floor(resTime % (24 * 60 * 60) % (60 * 60) % 60);
        let returnStr = {
            day: day,
            hour: hour,
            minute: minute,
            second: second
        };
        // let hours = time.getHours().toString().length < 2 ? "0" + time.getHours() : time.getHours();
        // let min = time.getMinutes().toString().length < 2 ? "0" + time.getMinutes() : time.getMinutes();
        // returnStr = time.getFullYear().toString() + "/" + (time.getMonth() + 1) + "/" + time.getDate() + " " + hours + ":" + min
        return returnStr
    }

}

const instance = DateFormat.Instance;
export default instance;